const path = require('path');

const Multer = require('koa-multer');

const {
  PICTURES_PATH,
} = require('../constants/file-path');

// 上传展示花卉详情图片接口
const uploadImg = Multer.diskStorage({
  destination: (req, file, cb) => {
    cb(null, PICTURES_PATH);
  },
  filename: (req, file, cb) => {
    let thePath = `${Date.now()}${path.extname(file.originalname)}`;
    cb(null, thePath);
  }
})

const productImformationUpload = Multer ({
  storage: uploadImg
})

const uploadProductInformation = productImformationUpload.single('imagePatch');

module.exports = {
  uploadProductInformation
}
